<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
    <title>ShellCheck: SC1068 – Don't put spaces around the `=` in assignments.</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
  </head>
  <body style="margin-left: auto; margin-right: auto; max-width: 800px">
    <h1>SC1068 – ShellCheck Wiki</h1>
    <a href="https://github.com/koalaman/shellcheck/wiki/SC1068">See this page on GitHub</a>
    <p style="display: none"><a href="index.html">Sitemap</a></p>
    <hr />
    <h1 id="dont-put-spaces-around-the--in-assignments">Don't put spaces
around the <code>=</code> in assignments.</h1>
<h3 id="problematic-code">Problematic code:</h3>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="SC1068.html#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">foo</span> = 42</span></code></pre></div>
<h3 id="correct-code">Correct code:</h3>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="SC1068.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="va">foo</span><span class="op">=</span>42</span></code></pre></div>
<h3 id="rationale">Rationale:</h3>
<p>Shells are space sensitive. <code>foo=42</code> means to assign
<code>42</code> to the variable <code>foo</code>. <code>foo = 42</code>
means to run a command named <code>foo</code>, and pass <code>=</code>
as <code>$1</code> and <code>42</code> as <code>$2</code>.</p>
<h3 id="exceptions">Exceptions</h3>
<p>If you actually wanted to run a command named foo and provide
<code>=</code> as the first argument, simply quote it to make ShellCheck
be quiet: <code>foo "=" 42</code>.</p>
    <hr />
    <p style='font-size: 80%'><a href="../index.html">ShellCheck</a> is a static analysis tool for shell scripts. This page is part of its documentation.</p>
  </body>
</html>


